/*
 * c5000_ext.c
 *
 *  Created on: 13.01.2013
 *      Author: Michael
 */

/*
 * ======== Standard MSP430 includes ========
 */
#include <msp430.h>

/*
 * ======== Project related includes ========
 */
#include "extensions/c5000/c5000_ext.h"

#define MASK45                  (BIT3+BIT5+BIT6+BIT7)
#define MASK80                  BIT4
#define MASK100                 (BIT3+BIT4+BIT6+BIT7)
#define MASK135                 BIT5
#define MASK225                 (BIT3+BIT4+BIT5+BIT7)
#define MASK260                 BIT6
#define MASK280                 (BIT3+BIT4+BIT5+BIT6)
#define MASK315                 BIT7

const unsigned char startSequence[8] = { MASK315, MASK280, MASK260, MASK225,
		MASK135, MASK100, MASK80, MASK45 };

void c5000ext_fastRotateLed(void) {
	P1OUT &= ~(BIT3 + BIT4 + BIT5 + BIT6 + BIT7 + BIT0);
	P1DIR |= BIT3 + BIT4 + BIT5 + BIT6 + BIT7;

	while (1) {
		unsigned char i = 8;

		/* Fast counter-clockwise sequence */
		while (i) {
			i--;
			P1OUT = startSequence[i];

			// software delay, enough to show all led's in one time slot
			volatile unsigned int j = 8000;
			do
				j--;
			while (j != 0);
		}

		// Turn off all LEDs
		P1OUT = 0;
	}
}
